<template>
  <div class="page-hero">
    <TopBar>
      <template v-slot:center>
        <div class="px-2 flex-1 py-2">
          <span class="text-white">王者荣耀</span>
          <span class="text-white pl-2">攻略站</span>
        </div>
      </template>
      <template v-slot:right>
        <router-link class="text-white py-2" to="/" tag="div"
          >更多英雄 &gt;</router-link
        >
      </template>
    </TopBar>
    <div class="top" :style="{ 'background-image': `url(${model.banner})` }">
      <div class="text-white info p-3 h-100 d-flex flex-column jc-end">
        <div class="fs-sm">{{ model.title }}</div>
        <h2 class="my-2">{{ model.name }}</h2>
        <div class="fs-xs">
          游戏职业：{{ model.categories.map((v) => v.name).join("/") }}
        </div>

        <div class="d-flex jc-between pt-2">
          <div class="scores d-flex ai-center" v-if="model.scores">
            <span>难度</span>
            <span class="badge bg-primary">{{ model.scores.difficult }}</span>
            <span>技能</span>
            <span class="badge bg-blue-1">{{ model.scores.skills }}</span>
            <span>攻击</span>
            <span class="badge bg-danger">{{ model.scores.attack }}</span>
            <span>生存</span>
            <span class="badge bg-dark">{{ model.scores.survive }}</span>
          </div>

          <span class="text-grey fs-sm">皮肤：10 &gt;</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import TopBar from "@/components/TopBar.vue";
export default {
  components: {
    TopBar,
  },
  props: {
    id: { require: true },
  },
  data() {
    return {
      model: {
        categories: [],
      },
    };
  },
  methods: {
    async fetch() {
      const res = await this.$http.get(`heroes/${this.id}`);
      this.model = res.data;
    },
  },

  created() {
    this.fetch();
  },
};
</script>

<style lang="scss" scoped>
.page-hero {
  .top {
    height: 50vw;
    background: #fff no-repeat top center;
    background-size: auto 100%;
  }

  .info {
    background: linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 1));
    .scores {
      .badge {
        margin: 0 0.25rem;
        display: inline-block;
        width: 1rem;
        height: 1rem;
        line-height: 0.9rem;
        text-align: center;
        border-radius: 50%;
        font-size: 0.6rem;
        border-radius: 1px solid rgba(255, 255, 255, 0.2);
      }
    }
  }
}
</style>
